package com.shangxia.monomer.study.thread.future;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

/**
 * @ProjectName: monomer
 * @ClassName: CompletableFutureDemo
 * @Time: 2021/10/7
 * @Author: zhouy
 * @Description:
 * @Experience:
 */

@Slf4j
public class CompletableFutureDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Integer> hhh = CompletableFuture.supplyAsync(() -> {
            System.out.println("hhhh");
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return 0;
        });

        System.out.println(hhh.get());

        System.out.println("---===");

        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    public static void any(){



    }
}
